<?php
if (!defined("_INDEX")) { header("Location: /"); die; }

if ($this_city != 0)
{
	$brokers = $db->getTable("select `B`.`name`,`B`.`address`,`B`.`phone`,`city`.`name` as `city_name` from `brokers` as `B`,`city` where `B`.`city_id` = '$this_city' and `B`.`city_id` = `city`.`city_id` order by `name`");
	
	$answer = "[";
	foreach ($brokers as $key => $broker){
		$answer .= '{"name":"'.$broker['name'].'","address":"'.$broker['address'].'","phone":"'.$broker['phone'].'","city":"'.$broker['city_name'].'"}';
		if ($key < count($brokers)-1)
			$answer .= ",";
	}
	echo $answer .= "]";
}

?>